﻿using UnityEngine;
using UnityEngine.UI;

namespace Zero.Dialogue
{
    public class UI_DialoguePanel : MonoBehaviour
    {
        public Text characterNameText;
        public Text bodyText;


        /// <summary>
        /// 设置对话框文本
        /// </summary>
        /// <param name="characterName">角色名字</param>
        /// <param name="body">文本主体</param>
        public void SetDialogueText(string characterName, string body)
        {
            // 根据角色名设置轮廓颜色 (这里是硬编码,需要再修改)
            var nameOutline = characterNameText.GetComponent<Outline>();
            if (nameOutline != null)
            {
                Color outlineColor;
                switch (characterName)
                {
                    case "小红":
                        outlineColor = Color.red;
                        break;
                    case "冒险家":
                        outlineColor = Color.green;
                        break;
                    default:
                        outlineColor = Color.white;
                        break;
                }

                outlineColor.a = nameOutline.effectColor.a;
                nameOutline.effectColor = outlineColor;
            }


            characterNameText.text = characterName;
            bodyText.text = body;

            // 激活对话框面板
            gameObject.SetActive(true);
        }
    }
}